class DistinctError(Exception):
    pass

class distinctdict(dict):
    def __setitem__(self,key,value):
        try :
            value_index = self.values().index(value)
            existing_key = self.keys()[value_index]
            if existing_key != key :
                raise DistinctError("this value already exists for '%s'" % str(self[existing_key]))
        except ValueError:
            pass
        #two ways to invoke a super class's method
        # super(distinctdict,self).method() or dict.method(self)

        super(distinctdict,self).__setitem__(key,value)


my = distinctdict()
my['a'] = 'value'
my['b'] = 'value'
print my
